<template>
  <div>
    <el-table
      :data="arr"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      default-expand-all
      :tree-props="{ children: 'children' }"
    >
      <el-table-column prop="id" label="用户编号" sortable width="180">
        
      </el-table-column>
      <el-table-column prop="username" label="用户名" sortable width="180">
      </el-table-column>
       <el-table-column prop="rolename" label="所属角色" sortable width="180">
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" 
           v-if="scope.row.status == 1"   
            >启用</el-button
          >
          <el-button type="info"  v-else
            >禁用</el-button
          >
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="edit(scope.row.uid)" 
            >编辑</el-button 
          >
          <el-button type="danger" 
             @click="del(scope.row.uid)"
           >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { reqroledelete ,requserdelete} from '../../../http/api';
import { successAlert } from "../../../utils";
export default {
    props:['info','arr'],
  data() {
      return {
       
      }
    },
  computed: {
    ...mapGetters({}),
  },
  methods: {
    ...mapActions({}),
    del(id){
        requserdelete({uid:id}).then(res => {
            console.log(res);
            successAlert(res.data.msg);
            this.info.isshow = false;
            this.$emit('init')
        })
    },
    edit(id){
        console.log(id);
        this.info.isshow = true;
        this.info.isAdd = false;
        this.$emit('willUpdate',id)
    }
  },
};
</script>
<style scoped lang="less">

</style>